label variable m_intrusion "Minority"

. label variable n_intrusion "Overall"

. label variable l_intrusion "Support"
label variable change_m "Minority change"
label variable change_n "Majority change"
label variable change_l "Support change"


gen m_intrusion = rowtotal(mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x)
*same for others*

*main regression results*
*coefplots go into appendix*
cd "C:\Users\phenne\Dropbox\Own Writing\in progress\RAS3\Outputs"
foreach X of varlist mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x   {
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Minority.doc", word label dec(2) append
}
coefplot mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x, keep (mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x) legend(off)

foreach X of varlist nx01x nx02x nx03x nx04x nx05x nx06x nx07x  {
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Majority1.doc", word dec(2) append
}
coefplot nx01x nx02x nx03x nx04x nx05x nx06x nx07x, keep(nx01x nx02x nx03x nx04x nx05x nx06x nx07x) legend(off)

foreach X of varlist nx08x nx09x nx10x nx11x nx12x nx13x nx14x {
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Majority2.doc", word label dec(2) append
}
coefplot nx08x nx09x nx10x nx11x nx12x nx13x nx14x, keep(nx08x nx09x nx10x nx11x nx12x nx13x nx14x) legend(off)


foreach X of varlist lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x {
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Support1.doc", word dec(2) append label 
}
coefplot lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x , keep (lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x) legend(off)

foreach X of varlist lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x {
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Support2.doc", word dec(2) append label 
}
coefplot lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x, keep(lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x) legend(off)

*graphs for article*
coefplot mx16x mx19x nx01x, keep(mx16x mx19x nx01x) legend(off)
coefplot lx30x lx31x lx36x lx42x lx27x, keep(lx30x lx31x lx36x lx42x lx27x) legend(off)

foreach X of varlist m_intrusion n_intrusion l_intrusion { 
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
outreg2 using "Composites.doc", word label dec(2) append
estimates store `X'
}
coefplot m_intrusion n_intrusion l_intrusion, keep(m_intrusion n_intrusion l_intrusion) legend(off)
*above is in appendix*
gen change_n_test = n_intrusion - l.n_intrusion


foreach X of varlist change_m change_n change_l { 
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
estimates store `X'
outreg2 using "Changes.doc", word dec(2) append
}
*below is in article*
coefplot change_m change_n change_l, keep(change_m change_l change_n)

*import bar graph data*
xtreg logdeaths change_n L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
twoway (bar coefficient model) (rcap  upperci  lowerci model), xlabel(1 2, valuelabel)

*robustness*
xtreg logdeaths nfactor_change L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
outreg2 using "factor_alternate.doc", word dec(2) label 

reg logdeaths change_n L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
outreg2 using "alt_tests.doc", word dec(2) label replace
xtreg logdeaths change_n L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion, fe
outreg2 using "alt_tests.doc", word dec(2) label append
xtreg logdeaths change_n L.logdeaths EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion, mle
outreg2 using "alt_tests.doc", word dec(2) label append

xtreg logdeaths change_n L.logdeaths logland Int_maxyear polity2_ loggdp logpop  Ethnic 
outreg2 using "alt_vars.doc", word dec(2) label replace
xtreg logdeaths change_n L.logdeaths logland Int_maxyear polity2_ loggdp logpop  Religion
outreg2 using "alt_vars.doc", word dec(2) label append
xtreg logdeaths change_n L.logdeaths logland Int_maxyear polity2_ loggdp logpop  EMAJISL
outreg2 using "alt_vars.doc", word dec(2) label append

xtreg logdeaths change_n L.logdeaths logland Int_maxyear polity2_ loggdp Ethnic  Religion EMAJISL
outreg2 using "alt_vars2.doc", word dec(2) label replace
xtreg logdeaths change_n L.logdeaths logpop Int_maxyear polity2_ loggdp Ethnic  Religion EMAJISL
outreg2 using "alt_vars2.doc", word dec(2) label append
xtreg logdeaths `X' L.logdeaths EMAJISLA logland Int_maxyear loggdp logpop  Ethnic Religion
outreg2 using "alt_vars2.doc", word dec(2) label append
xtreg loggovt change_n L.loggovt EMAJISLA logland Int_maxyear polity2_ loggdp logpop  Ethnic Religion
outreg2 using "alt_vars2.doc", word dec(2) label append









*factors*
factor mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x
rotate, varimax
screeplot
factor mx13x mx14x mx15x mx16x mx17x mx18x mx19x mx20x, factor(2)
rotate, varimax
help factor
gen mfactor1 mfactor2
help factor
predict mfactor1 mfactor2
factor nx01x nx02x nx03x nx04x nx05x nx06x nx07x nx08x nx09x nx10x nx11x nx12x nx13x nx14x
rotate, varimax
screeplot
factor nx01x nx02x nx03x nx04x nx05x nx06x nx07x nx08x nx09x nx10x nx11x nx12x nx13x nx14x, factor(3)
rotate, varimax
predict nfactor1 nfactor2 nfactor3
factor lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x
rotate, varimax
screeplot
screeplot
factor lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x, factor(1)
rotate, varimax
predict lfactorv1
factor lx27x lx28x lx29x lx30x lx31x lx32x lx33x lx34x lx35x lx36x lx37x lx38x lx39x lx40x lx41x lx42x lx43x, factor(2)
rotate, varimax
predict lfactorv2_1 lfactorv2_2


